package com.order.service;

import com.order.entity.OrderProgress;
import com.order.mapper.OrderProgressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 订单进度服务
 */
@Service
public class OrderProgressService {

    @Autowired
    private OrderProgressMapper orderProgressMapper;

    /**
     * 根据订单ID获取进度列表
     */
    public List<OrderProgress> getProgressByOrderId(Long orderId) {
        return orderProgressMapper.selectByOrderId(orderId);
    }

    /**
     * 添加订单进度
     */
    public void addProgress(Long orderId, Long userId, String content, Integer progressType) {
        OrderProgress progress = new OrderProgress();
        progress.setOrderId(orderId);
        progress.setUserId(userId);
        progress.setContent(content);
        progress.setProgressType(progressType);
        progress.setCreateTime(LocalDateTime.now());
        
        orderProgressMapper.insert(progress);
    }

    /**
     * 删除订单进度
     */
    public void deleteProgress(Long id) {
        orderProgressMapper.deleteById(id);
    }
}